package cn.edu.java.internet;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class DatagramSocketClient {
    public static void main(String[] args) throws IOException {
        DatagramSocket datagramSocket = new DatagramSocket(88);

        byte[] bytes = new byte[1024];
        DatagramPacket datagramPacket = new DatagramPacket(bytes, bytes.length);

        datagramSocket.receive(datagramPacket);

        String s = new String(datagramPacket.getData(), 0, datagramPacket.getLength());

        System.out.println(s + "\n" + datagramPacket.getAddress());
    }
}
